﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SAPbobsCOM;
using System.Reflection;
using System.Runtime.Serialization;

namespace CompanySyncProject
{
    public class DIPayment : BaseRun
    {
        public DIPayment(Company co, System.IO.StreamWriter lo)
            : base(co, lo)
        {

        }

        public override void Run()
        {
            oCompany.XmlExportType = BoXmlExportTypes.xet_ExportImportMode;

            //SAPbobsCOM.StockTransfer ostfr = oCompany.GetBusinessObject(BoObjectTypes.oStockTransferDraft);
            //ostfr.DocObjectCode = BoObjectTypes.oStockTransfer;
            //ostfr.FromWarehouse = "01";
            //ostfr.ToWarehouse = "02";
            //ostfr.Lines.ItemCode = "Child001";
            //ostfr.Add();

            //ostfr.GetByKey(2);
            //ostfr.SaveToFile(@"..\..\test\stocktransferdraft1.txt");

            //SAPbobsCOM.StockTransfer ostfr = oCompany.GetBusinessObjectFromXML(@"..\..\test\stocktransferdraft2.txt", 0);
            //string fromwhs = ostfr.FromWarehouse;
            //string towhs = ostfr.ToWarehouse;
            //string itemcode = ostfr.Lines.ItemCode;
            //ostfr.Add();

            //SAPbobsCOM.StockTransfer ostfr = oCompany.GetBusinessObject(BoObjectTypes.oStockTransferDraft);
            //ostfr.GetByKey(3);
            //ostfr.SaveDraftToDocument();

            /*
            SAPbobsCOM.StockTransfer ostfr = oCompany.GetBusinessObject((BoObjectTypes)(1250000001));
            ostfr.FromWarehouse = "01";
            ostfr.ToWarehouse = "02";
            ostfr.Lines.ItemCode = "Child001";
            ostfr.Lines.Quantity = 1;
            ostfr.Comments = "added by DI";
            ostfr.Add();
            */

            SAPbobsCOM.StockTransfer ost = oCompany.GetBusinessObject(BoObjectTypes.oStockTransfer);
            //ost.FromWarehouse = "01";
            ost.Lines.BaseType = (InvBaseDocTypeEnum)(5);
            ost.Lines.BaseEntry = 1;
            ost.Lines.BaseLine = 0;
            ost.Add();

            /*
            SAPbobsCOM.IPayments opmt = oCompany.GetBusinessObject(BoObjectTypes.oIncomingPayments);
            //opmt.GetByKey(1);
            //opmt.SaveXML(@"..\..\test\pmtexport1.txt");
            opmt.CardCode = "C002";
            opmt.Invoices.DocEntry = 8;
            opmt.Invoices.DocLine = 0;
            opmt.Invoices.InstallmentId = 1;
            //opmt.Invoices.SumApplied = 10;
            opmt.Invoices.InvoiceType = BoRcptInvTypes.it_Invoice;
            opmt.Invoices.AppliedFC = 10;
            opmt.TransferAccount = "100201";
            opmt.TransferSum = 60;
            opmt.DocCurrency = "RMB";
            //opmt.CashAccount = "100101";
            //opmt.CashSum = 10;
            opmt.Add();
            */

            string errMsg = oCompany.GetLastErrorDescription();
            int errcode = oCompany.GetLastErrorCode();
        }
    }
}
